package com.linwen.tips.pattern.optimize;

abstract class Template {

    public final void prepareBeverage() {
        boilWater();
        brew();
        pourInCup();
        addCondiments();
    }

    private void boilWater() {
        System.out.println("Boiling water");
    }

    abstract void brew();

    private void pourInCup() {
        System.out.println("Pouring into cup");
    }

    abstract void addCondiments();
}

class Coffee extends Template {
    @Override
    void brew() {
        System.out.println("Brewing coffee grinds");
    }

    @Override
    void addCondiments() {
        System.out.println("Adding sugar and milk");
    }
}

class Tea extends Template {
    @Override
    void brew() {
        System.out.println("Steeping the tea bag");
    }

    @Override
    void addCondiments() {
        System.out.println("Adding lemon");
    }
}

